package com.atguigu.encapsolation.one;

public class Rectangle {
   /* public double length;
    public double width;*/
    private double length;
    private double width;

    public Rectangle() {
    }

    public Rectangle(double length, double width) {
        if(length<=0 || width<=0){
            System.out.println("长、宽必须是正数");
            return;
        }
        this.length = length;
        this.width = width;
    }

    //set：设置或修改某个属性的值
    public void setLength(double length){
        if(length<=0){
            System.out.println("长必须是正数");
            return;
        }
        this.length = length;
    }
    public void setWidth(double width){
        if(width<=0){
            System.out.println("宽必须是正数");
            return;
        }
        this.width = width;
    }

    //get是用于获取某个属性的值
    public double getLength(){
        return length;
    }
    public double getWidth(){
        return width;
    }

}
